.TH std::remove_reference 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::remove_reference \- std::remove_reference

.SH Synopsis
   Defined in header <type_traits>
   template< class T >              \fI(since C++11)\fP
   struct remove_reference;

   If the type T is a reference type, provides the member typedef type which is the
   type referred to by T. Otherwise type is T.

   If the program adds specializations for std::remove_reference, the behavior is
   undefined.

.SH Member types

   Name Definition
   type the type referred by T or T if it is not a reference

.SH Helper types

   template< class T >                                             \fI(since C++14)\fP
   using remove_reference_t = typename remove_reference<T>::type;

.SH Possible implementation

   template<class T> struct remove_reference { typedef T type; };
   template<class T> struct remove_reference<T&> { typedef T type; };
   template<class T> struct remove_reference<T&&> { typedef T type; };

.SH Example


// Run this code

 #include <iostream>
 #include <type_traits>

 int main()
 {
     std::cout << std::boolalpha;

     std::cout << "std::remove_reference<int>::type is int? "
               << std::is_same<int, std::remove_reference<int>::type>::value << '\\n';
     std::cout << "std::remove_reference<int&>::type is int? "
               << std::is_same<int, std::remove_reference<int&>::type>::value << '\\n';
     std::cout << "std::remove_reference<int&&>::type is int? "
               << std::is_same<int, std::remove_reference<int&&>::type>::value << '\\n';
     std::cout << "std::remove_reference<const int&>::type is const int? "
               << std::is_same<const int,
                               std::remove_reference<const int&>::type>::value << '\\n';
 }

.SH Output:

 std::remove_reference<int>::type is int? true
 std::remove_reference<int&>::type is int? true
 std::remove_reference<int&&>::type is int? true
 std::remove_reference<const int&>::type is const int? true

.SH See also

   is_reference         checks if a type is either an lvalue reference or rvalue
   \fI(C++11)\fP              reference
                        \fI(class template)\fP
   add_lvalue_reference
   add_rvalue_reference adds an lvalue or rvalue reference to the given type
   \fI(C++11)\fP              \fI(class template)\fP
   \fI(C++11)\fP
   remove_cvref         combines std::remove_cv and std::remove_reference
   (C++20)              \fI(class template)\fP
